home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / perl / prlbkxmp.lha / ch6 / retab < prev    next >
Text File  |  1991-01-08  |  260b  |  14 lines

  1. #!/usr/bin/perl
  2.  
  3. # Usage: retab [-<tabwidth>] [files]
  4.  
  5. $sw = 4;
  6. $sw = $1, shift if $ARGV[0] =~ /^-(\d+)/;
  7.  
  8. while (<>) {
  9.     s#^(\t+)#' ' x (length($1) * 8)#e;
  10.     s#^( *)#' ' x (length($1) * $sw / 8)#e;
  11.     s#^(( {8})*)#"\t" x (length($1) / 8)#e;
  12.     print;
  13. }
  14.